package com.lvbaoins.creditapp.util;


/**
 * 密码检查
 *
 * @author liwei
 */
public class PasswordUtil {

    /**
     * @param code 用户名
     * @param password 密码（未加密）
     * @return
     */
    public static String createPassword(String password, String code) {
        String pwd = code + password + code;
        try {
            pwd = MD5Encrypt.getMessageDigest(pwd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return pwd;
    }

    /**
     * 验证用户密码是否正确
     *
     * @param user     用户
     * @param password 待验证密码
     * @return
     */
    public static boolean check(String userCode, String password, String checkPasword) {
        String checkPwd = createPassword(userCode, checkPasword);
        return password.equals(checkPwd);
    }
}
